package com.whu.bookstore.entity;

import java.util.Arrays;

/**
 * Created by chenshaojie on 2018/5/18,14:03.
 */
public class Book {
    private int id;
    private String name;
    private byte[] cover;
    private String description;
    private String author;
    private int year;
    private String press;
    private double price;

    public int getId () {
        return id;
    }

    public void setId (int id) {
        this.id = id;
    }

    public String getName () {
        return name;
    }

    public void setName (String name) {
        this.name = name;
    }

    public byte[] getCover () {
        return cover;
    }

    public void setCover (byte[] cover) {
        this.cover = cover;
    }

    public String getDescription () {
        return description;
    }

    public void setDescription (String description) {
        this.description = description;
    }

    public String getAuthor () {
        return author;
    }

    public void setAuthor (String author) {
        this.author = author;
    }

    public int getYear () {
        return year;
    }

    public void setYear (int year) {
        this.year = year;
    }

    public String getPress () {
        return press;
    }

    public void setPress (String press) {
        this.press = press;
    }

    public double getPrice () {
        return price;
    }

    public void setPrice (double price) {
        this.price = price;
    }

    @Override
    public boolean equals (Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Book book = (Book) o;

        if (id != book.id) return false;
        if (year != book.year) return false;
        if (Double.compare(book.price, price) != 0) return false;
        if (name != null ? !name.equals(book.name) : book.name != null) return false;
        if (!Arrays.equals(cover, book.cover)) return false;
        if (description != null ? !description.equals(book.description) : book.description != null) return false;
        if (author != null ? !author.equals(book.author) : book.author != null) return false;
        if (press != null ? !press.equals(book.press) : book.press != null) return false;

        return true;
    }

    @Override
    public int hashCode () {
        int result;
        long temp;
        result = id;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + Arrays.hashCode(cover);
        result = 31 * result + (description != null ? description.hashCode() : 0);
        result = 31 * result + (author != null ? author.hashCode() : 0);
        result = 31 * result + year;
        result = 31 * result + (press != null ? press.hashCode() : 0);
        temp = Double.doubleToLongBits(price);
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        return result;
    }
}
